package com.yjhb.android.sbz.http;

import com.jojo.android.zxlib.entity.Result;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * 创建者 zx
 * 创建时间 2020/11/17 14:42
 */
public class HttpTool {
    private final String TAG = "HttpTool";

    /**
     * 传入一个被观察的网络
     *
     * @param observable 一个被观察的网络
     * @param <T>
     */
    public static <T> void request(Observable<Result<T>> observable, HttpObserver<T> observer) {
        observable
                .subscribeOn(Schedulers.io()) //在IO线程执行网路请求
                .observeOn(AndroidSchedulers.mainThread()) //在UI线程得到数据
                .subscribe(observer);
    }

}
